package com.logic.AccountControl;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.context.db.DBContext;

public class AdminChangeAccountTypeLogic {

	public String  changeStateByTypeThroughProcedure( String type, String id ){

		Connection conn = null;

		CallableStatement cst = null;

		ResultSet rs = null;

		conn = DBContext.getDBInstance( DBContext.MYSQL ).getDBConnection();

		String returnStr = "1";

		String sql = "{call db.adminchangeaccounttype_proc(?,?)}";

		try {
			cst = conn.prepareCall( sql );

			cst.setInt( 1, Integer.valueOf( id ) );
			cst.setString( 2, type );

			cst.execute();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{

			if( rs != null ){

				try {
					rs.close();

					rs = null;
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}


			if( cst != null ){

				try {
					cst.close();

					cst = null;
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}
		}

		return returnStr;

	}

}
